import { purple, green, gold, red } from '@ant-design/colors'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'

let colors = ''
purple.forEach((color, index) => {
  // css variable 变量
  // --bh-color-primary: #722ed1
  colors += `--bh-color-primary-${index + 1}: ${color};\n`
})

colors += '\n'
green.forEach((color, index) => {
  // css variable 变量
  // --bh-color-primary: #722ed1
  colors += `--bh-color-success-${index + 1}: ${color};\n`
})

colors += '\n'
gold.forEach((color, index) => {
  // css variable 变量
  // --bh-color-primary: #722ed1
  colors += `--bh-color-warning-${index + 1}: ${color};\n`
})

colors += '\n'
red.forEach((color, index) => {
  // css variable 变量
  // --bh-color-primary: #722ed1
  colors += `--bh-color-error-${index + 1}: ${color};\n`
})

const baseUrl = fileURLToPath(new URL('../', import.meta.url))
const cssFile = path.resolve(baseUrl, 'packages/bh-ui/src/style/theme/colors.css')
fs.writeFileSync(cssFile, `:root{\n${colors}\n}`)
console.log('success')